package top.blacknota.web.controller;

import act.controller.Controller;
import act.inject.SessionVariable;
import org.osgl.http.H;
import org.osgl.mvc.annotation.Before;
import org.osgl.util.S;

import javax.inject.Inject;

/**
 * @author 撒哈拉来的企鹅
 * @date 2018-2-8
 */
public class Global extends Controller.Util {
    @Inject
    H.Session session;

    @Before(except = {".*\\.UserController\\.form", ".*\\.UserController\\.login"})
    public void ensureLoggedIn(@SessionVariable("name") String name) {
        System.out.println("###############");
        System.out.println(name);
        System.out.println(session.get("name"));
        System.out.println("###############");
        name = session.get("name");
        redirectIf(S.blank(name), "/user/login/form");
    }
//    public void before() {
//        if ($.isNull(session.get("name"))) {
//            redirect("/user/login/form");
//        }
//    }
}
